import request from '@/utils/request'

/**
 * 通过code获取用户信息
 *
 * @param {string} code
 * @returns
 */
export function getUserByCode(code) {
  return request({
    url: '/user/ssoLogin',
    method: 'get',
    params: {
      code
    }
  })
}

/**
 * 获取config
 *
 * @returns
 */
export function getWxConfig(type = '') {
  return request({
    url: '/weixin/config',
    method: 'post',
    data: {
      signUrl: encodeURIComponent(location.href),
      type
    }
  })
}

/**
 *  获取acess tooken
 *
 * @returns
 */
export function getAcessToken() {
  return request({
    url: '/weixin/token',
    method: 'get'
  })
}

/**
 * 发送文本卡片消息
 *
 * @param {object} data
 * @returns
 */
export function sendMsgCard(data) {
  return request({
    url: '/weixin/message',
    method: 'post',
    data
  })
}
